﻿using TraumaCenterSystem.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using TraumaCenterSystem.TraumaCenterManage;

namespace TraumaCenterSystem.Bll
{
    public class MedicalRecordsManager : BaseManager
    {
        public static TraumaCenterManageSoapClient service = new TraumaCenterManageSoapClient();


        /// <summary>
        /// 获取当前急救人列表
        /// </summary>
        /// <returns></returns>
        public static OperateResult GetPathNameList()
        {
            OperateResult resultInfo = new OperateResult();
            try
            {
                ResultHelperOfString result = service.GetPathNameList();
                if (result.S)
                {
                    resultInfo.Result = 1;
                    resultInfo.Body = result.D;
                }
                else
                {
                    resultInfo.Result = 0;
                    resultInfo.Body = result.M;
                }
            }
            catch (Exception ex)
            {
                resultInfo.Result = -1;
                resultInfo.Body = ex.Message;
            }

            return resultInfo;
        }

        /// <summary>
        /// 根据诊疗路径ID获取模板或内容
        /// </summary>
        /// <param name="pathId"></param>
        /// <returns></returns>
        public static OperateResult GetDiagnosticPathTemp(int pathId, string patientId)
        {
            OperateResult resultInfo = new OperateResult();
            try
            {
                ResultHelperOfString result = service.GetDiagnosticPathTemp(pathId, patientId);
                if (result.S)
                {
                    resultInfo.Result = 1;
                    resultInfo.Body = result.D;
                }
                else
                {
                    resultInfo.Result = 0;
                    resultInfo.Body = result.M;
                }
            }
            catch (Exception ex)
            {
                resultInfo.Result = -1;
                resultInfo.Body = ex.Message;
            }
            return resultInfo;
        }

        /// <summary>
        /// 通过患者ID获取EpiduralHematoma硬膜外血肿数据
        /// </summary>
        /// <returns></returns>
        public static OperateResult Get_EpiduralHematoma(string patientId)
        {
            OperateResult resultInfo = new OperateResult();
            try
            {
                ResultHelperOfString result = service.Get_EpiduralHematoma(patientId);
                if (result.S)
                {
                    resultInfo.Result = 1;
                    resultInfo.Body = result.D;
                }
                else
                {
                    resultInfo.Result = 0;
                    resultInfo.Body = result.M;
                }
            }
            catch (Exception ex)
            {
                resultInfo.Result = -1;
                resultInfo.Body = ex.Message;
            }
            return resultInfo;
        }
        /// <summary>
        /// 新增或修改病人病历(EpiduralHematoma硬膜外血肿数据)
        /// </summary>
        /// <param name="patientViewModel"></param>
        /// <returns></returns>
        public static OperateResult Set_EpiduralHematoma(string patientViewModel)
        {
            OperateResult resultInfo = new OperateResult();
            try
            {
                ResultHelperOfBoolean result = service.Set_EpiduralHematoma(patientViewModel);
                if (result.S)
                {
                    resultInfo.Result = 1;
                    resultInfo.Body = result.M;
                }
                else
                {
                    resultInfo.Result = 0;
                    resultInfo.Body = result.M;
                }
            }
            catch (Exception ex)
            {
                resultInfo.Result = -1;
                resultInfo.Body = ex.Message;
            }
            return resultInfo;
        }

        /// <summary>
        /// 修改时间点数据
        /// </summary>
        /// <param name="Patient_ID"></param>
        /// <returns></returns>
        public static OperateResult Set_ExecutionDate(string patientViewModel)
        {
            OperateResult resultInfo = new OperateResult();
            try
            {
                ResultHelperOfBoolean result = service.Set_ExecutionDate(patientViewModel);
                //ResultHelperOfBoolean result = new ResultHelperOfBoolean();
                if (result.S)
                {
                    resultInfo.Result = 1;
                    resultInfo.Body = result.M;
                }
                else
                {
                    resultInfo.Result = 0;
                    resultInfo.Body = result.M;
                }
            }
            catch (Exception ex)
            {
                resultInfo.Result = -1;
                resultInfo.Body = ex.Message;
            }
            return resultInfo;
        }

        /// <summary>
        /// 获取时间点数据
        /// </summary>
        /// <param name="patientId"></param>
        /// <returns></returns>
        public static OperateResult Get_PatientTimePath(string Patient_ID)
        {
            OperateResult resultInfo = new OperateResult();
            try
            {
                ResultHelperOfString result = service.Get_PatientTimePath(Patient_ID);
               // ResultHelperOfString result = new ResultHelperOfString();
                if (result.S)
                {
                    resultInfo.Body = result.D;
                    resultInfo.Result = 1;
                }
                else
                {
                    resultInfo.Result = 0;
                    resultInfo.Body = result.M;
                }
            }
            catch (Exception ex)
            {
                resultInfo.Result = -1;
                resultInfo.Body = ex.Message;
            }
            return resultInfo;
        }
    }
}